package game;

import game.entities.Bullet;
import game.entities.Player;
import game.gfx.Screen;
import level.Level;

public class GameEvents
{

	Level level;
	long bulletShotTime = 0;
	
	public GameEvents()
	{

	}
	
	public void renderPlayerEvents(Screen screen, int x, int y, InputHandler input, Player player, Level level)
	{
		long now = System.currentTimeMillis();
		
		if (input.shoot.isPressed() && (now - bulletShotTime) > Bullet.bulletReloadTime)
		{
			int xPos = Player.getXPos();
			int yPos = Player.getYPos();
			int shootingDir = Player.getDir();
			int xModifier = 0;
			int yModifier = 0;
			
			if (shootingDir == 0)
			{
				yModifier = -13;
			}
			if (shootingDir == 1)
			{
				yModifier = 4;
			}
			if (shootingDir == 2)
			{
				xModifier = -9;
				yModifier = -4;
			}
			if (shootingDir == 3)
			{
				xModifier = 9;
				yModifier = -4;
			}
			
			Game.bullet = new Bullet(level, xPos + xModifier, yPos + yModifier);
			level.addEntity(Game.bullet);
			
			bulletShotTime = System.currentTimeMillis();
		}
	}
}
